package com.thoughtworks.preuniversityprogram.biblioteca;

import java.util.List;

/**
 * Created by padmavb on 6/10/14.
 */
public class CheckOut extends Library {

    public List<Book> checkOutBook(String bookToCheckOut,List<Book> checkOutBookObjects){

        int index=0;
        createListOfBookObjects();

        Book book=isAvailable(bookToCheckOut);
        if(book!=null){

            for(index=0;index<checkOutBookObjects.size();index++){

                if(bookToCheckOut.equals(checkOutBookObjects.get(index).getTitle())){

                    System.out.print("That book is not available\n");
                    break;
                }
            }
            if(index==checkOutBookObjects.size()){

                System.out.print("Thank you enjoy the book\n");
                checkOutBookObjects.add(book);
            }
        }
        else
            System.out.print("That book is not available\n");
        return checkOutBookObjects;
    }
}
